package com.jiyi.common;

import com.android.volley.VolleyError;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;

import android.content.Context;

public abstract class JsonInterface<T> {
	private Context mContext;
	private Listener<T> mListener;
	private ErrorListener mErrorListtener;
	public JsonInterface(Context context){
		this.mContext = context;
	}

	public abstract void jsonSuccess(T result);
	public abstract void josnError(VolleyError error);
	
	
	public Listener<T> JsonListener(){
		mListener = new Listener<T>(){

			@Override
			public void onResponse(T response) {
				jsonSuccess(response);
				
			}
		};
		return mListener;
		
	}

	public ErrorListener errorListener() {
        mErrorListtener = new ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
            	josnError(error);
            }
        };
        return mErrorListtener;
    }
	
}
